<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8"
	contentType="text/html;charset=UTF-8"%>
<%@ include file="/includes/taglibs.jsp"%>
<html>
<head>
<title>汽车颜色管理</title>
	<meta name="menu" content="carMgr" />
	

</head>
<body>
<form id="colorForm" action="carColor.do?action=save" method="post" style="margin: 0px;" target="_self">

<% String pageFlag=(String)request.getAttribute("pageFlag"); 
   String root = request.getContextPath();	
   String repath = request.getContextPath();
   System.out.println("repath=="+repath);
%>
<%if("AddPage".equals(pageFlag)){%>
<h1>新增颜色配方</h1>
<table width="100%" cellpadding="4" cellspacing="0" border="0">
<tr >
	<td colspan="1">颜色图片:</td>
    <td>
    <span id="displayImage">
    <img id="preimage" src="<%=request.getContextPath() %>/pages/image/car_privew.jpg"   height='150px' width='200px'/>
    </span>
	<input type="hidden" name="imageName" id="_fileName"/>
	<input type="hidden" name="imageLocation" id="_realfilePath"/>
     
     	<BUTTON aria-disabled=false  onclick="uploadshow()" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role=button type=button jQuery191036113586339611503="24">
	<SPAN class=ui-button-text>上传</SPAN></BUTTON>
	
	</td>
</tr>

<tr >
	<td colspan="1">颜色名称:</td>
    <td>
	<input type="text" name="colorName" style="width:400px;" />
	</td>
</tr>	
<tr >
	<td colspan="1">配方人:</td>
    <td>
	<input type="text" name="userId" style="width:400px;" />
	</td>
</tr>
<tr>
	<td colspan="1">配方状态:</td>
	 <td>
	<select name="state">
		<option value="1">正常</option>
		<option value="0">不正常</option>
		</select>
	</td>
</tr>

<tr >
	<td colspan="1">RGB值:</td>
    <td>
	<input type="text" name="rgbValue" style="width:400px;" />
	</td>
</tr>
</table> 

<%}else{%>

<h1>修改颜色配方</h1>
<table width="100%" cellpadding="4" cellspacing="0" border="0">
<c:forEach var="color" items="${colorObj}">
<input type="hidden" name="colorId" value="<c:out value='${color.id}'/>"/>
	<input type="hidden" name="imageLocation" id="_realfilePath" value="<c:out value='${color.imageLocation}'/>"/>


<tr >
	<td colspan="1">颜色图片:</td>
    <td>
    <span id="displayImage">
    <img src="<%=request.getContextPath()%>/image/id/<c:out value='${color.imageLocation}'/>" width="200px" height="200px" id="preimage"/>
    </span>
     	<BUTTON aria-disabled=false  onclick="uploadshow()" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role=button type=button jQuery191036113586339611503="24">
	<SPAN class=ui-button-text>上传</SPAN></BUTTON>
	
	</td>
</tr>

<tr >
    <td colspan="1">颜色名称:</td>
	<td><input type="text" name="colorName" value= "<c:out value='${color.colorName}'/>" style="width:400px;" />
	</td>
</tr>	
<tr >
	<td colspan="1">配方人:</td>
    <td>
	<input type="text" name="userId" value= "<c:out value='${color.userId}'/>" style="width:400px;" />
	</td>
</tr>
<tr>
	<td colspan="1">配方状态:</td>
	 <td>
	<select name="state">
		<option value="1">正常</option>
		<option value="0">不正常</option>
		</select>
	</td>
</tr>
<tr >
	<td colspan="1">RGB值:</td>
    <td>
	<input type="text" name="rgbValue" value= "<c:out value='${color.rgbValue}'/>" style="width:400px;" />
	</td>
</tr>
</c:forEach>
</table> 
<%} %>

<table width="100%" cellpadding="4" cellspacing="0" border="0">
<tr align="center"><td>
	
	<BUTTON aria-disabled=false  onclick="saveColorInfo()" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role=button type=button jQuery191036113586339611503="24">
	<SPAN class=ui-button-text>保存</SPAN></BUTTON>
	
	
	<BUTTON aria-disabled=false  onclick="javascript:history.go(-1)" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role=button type=button jQuery191036113586339611503="24">
	<SPAN class=ui-button-text>返回</SPAN></BUTTON>
	
</td></tr>	
</table>
	<div id="dialog-modal" style="display: none;overflow: hidden;" title="文件上传 "> 
		<iframe src="uploadFile.do?action=goFileUpload&pageStyle=showpage&fileType=jpg&maxSize=5" frameborder=0 width="100%" height="100"  id="uploadframe" style="overflow: hidden;" name="uploadframe">
		</iframe>
	</div>
</form>
<script type="text/javascript">
function saveColorInfo(){
	var frmObj=document.getElementById("colorForm");
	alert("开始保存");
	frmObj.submit();	
}

function uploadshow(){ 
		$( "#dialog-modal" ).dialog({
			height: 150,
			width: 400,
			modal: true,buttons: {
				"上传 ": function() {
					window.frames["uploadframe"].window.submitform();
				}
			}
		});
}

/**  
 * 回调函数,获取上传文件信息  
 * realName真实文件名  
 * saveName文件保存名  
 * maxSize文件实际大小  
 */  
function callback(realName,saveName){ 
	$("#_fileName").val(saveName);
    $("#_realfilePath").val(realName);  
    document.getElementById("preimage").src = "<%=request.getContextPath()%>/image/id/"+realName;
    $( "#dialog-modal" ).dialog("close");
    //回调后其它操作  
}  
</script>

</body>
</html>
